home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows Expert
/
Windows Expert.iso
/
windownt
/
shutdo.zip
/
SHUTDOWN.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-29
|
2KB
|
63 lines
//
// Shutdown - utility
// ==================
//
// Programm Shutdown.exe
//
// Parameter R: loest einen Neustart aus
// ohne Parameter: normaler Shutdown
// Mit anderem Parameter: Hilfe
//
#include <windows.h>
#include <stdio.h>
void main(argc,argv)
int argc;
char *argv[];
{
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
CHAR buffer[80];
/* Get the Process Token */
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {
printf ( buffer, "OpenProcessToken Error #%d", GetLastError ());
}
/* Get the LUID for shutdown privilege */
LookupPrivilegeValue(NULL, TEXT("SeShutdownPrivilege"),
&tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1; /* one privilege to set */
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
/* Get shutdown privilege for this process. */
if (!AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
(PTOKEN_PRIVILEGES)NULL, 0)) {
printf ( buffer, "AdjustTokenPrivileges Error #%d", GetLastError ());
}
if (argc<2)
{InitiateSystemShutdown(NULL, NULL, 0, FALSE, FALSE);
exit(1);}
if ((argv[1][0]== 114) || (argv[1][0]== 82)){
InitiateSystemShutdown(NULL, NULL, 0, FALSE, TRUE);
exit(1);}
if ((argv[1][0]== 102) || (argv[1][0]== 70)){
InitiateSystemShutdown(NULL, NULL, 0, TRUE, TRUE);
exit(1);}
printf("Shutdown - Utility V. 1.01 \n");
printf("shutdown - Shutdown without reboot\n");
printf("shutdown r - Shutdown with reboot\n");
printf("shutdown f - FORCED Shutdown with reboot\n");
printf("This utility may be freely distributed as long as it remains unchanged.\n");
printf("Please forward suggestions to Martin Sieber (100142,2756)\n");;
printf("Dedicated to the Windows NT community\n");
}